Python does not support ternary operators in C + +? : The alternative is ... if ..... else ...For example, use the following syntax to achieve a minimum value of three digits.ND1 if nD1
The correct method of the Python ternary operator
Because
The trinocular operator is an important part of C language. The conditional operator is the only operator with three operands, also known as a ternary operator.In C-style languages, the ternary operator is in the following form:? : But there is no
Ternary operator Usage Example:
The ternary operator, as the first name indicates, requires three operands.
Grammar is a condition? Result 1: Results 2;. Here you write the terms on the question mark (?) followed by a colon (:) separated by a
Python does not support ternary operators in C + +? :, the alternative method is ... if ... else ...
For example, use the following syntax to achieve the minimum value of three numbers.
ND1 if nD1
The correct method for Python ternary operators
Test Object
1,unity script (C #)2,c# DLL (MCS build dynamic link library imported into unity)3,c Native Code (LLVM compiled after Unity) is tested function source code
(C #): Two random number array for size comparison, one array to save large
An operator is a particular symbol or expression used to examine, modify, or merge variables. For example, with the sum operator + you can sum two digits (such as let i = 1 + 2); a slightly more complex example has logic and operator && (e.g. if
(1) variable = a if exper else B(2) variable = (exper and [B] or [c]) [0](2) variable = exper and B or c
The above three methods can achieve the goal, similar to the C language variable = exper? B: c; that is, if the value of the exper expression is
Currently, most advanced languages support "?". The ternaryoperator corresponds to the following expression: condition? Valueiftrue: valueiffalse. It is strange that such a common operator python does not support python and does not support ternary
This operator is relatively rare because it has three operational objects. But it does belong to one of the operators because it eventually generates a value. This is different from the common If-else statement described in the latter section of
Does python support ternary operators in C/C ++? :, The alternative method is... if... else...For example, the following syntax is used to calculate the minimum value of three numbers.ND1 if nD1
The correct method for python ternary
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.